
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>数组 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="对象.html" />
    
    
    <link rel="prev" href="函数.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="变量.html">
            
                <a href="变量.html">
            
                    
                    变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="解构.html">
            
                <a href="解构.html">
            
                    
                    解构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="字符串.html">
            
                <a href="字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6" data-path="数组.html">
            
                <a href="数组.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="对象.html">
            
                <a href="对象.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="prototype.html">
            
                <a href="prototype.html">
            
                    
                    prototype
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="Promise.html">
            
                <a href="Promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="模块化.html">
            
                <a href="模块化.html">
            
                    
                    模块化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="class和继承.html">
            
                <a href="class和继承.html">
            
                    
                    class和继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="this.html">
            
                <a href="this.html">
            
                    
                    this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="Symbol和generator.html">
            
                <a href="Symbol和generator.html">
            
                    
                    Symbol和generator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="async_await.html">
            
                <a href="async_await.html">
            
                    
                    async_await
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="Set和WeakSet.html">
            
                <a href="Set和WeakSet.html">
            
                    
                    Set和WeakSet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="Map和WeakMap.html">
            
                <a href="Map和WeakMap.html">
            
                    
                    Map和WeakMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="数字和Math.html">
            
                <a href="数字和Math.html">
            
                    
                    数字和Math
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="正则.html">
            
                <a href="正则.html">
            
                    
                    正则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="Proxy.html">
            
                <a href="Proxy.html">
            
                    
                    Proxy
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >数组</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6570;&#x7EC4;">&#x6570;&#x7EC4;</h1>
<p>array&#x7684;&#x5FAA;&#x73AF;:</p>
<ul>
<li>arr.forEach()</li>
<li>arr.map()</li>
<li>arr.filter()</li>
<li>arr.some()</li>
<li>arr.every</li>
</ul>
<p>&#x4EE5;&#x4E0A;&#x8FD9;&#x51E0;&#x4E2A;&#x53EF;&#x4EE5;&#x63A5;&#x6536;&#x4E24;&#x4E2A;&#x53C2;&#x6570;:<br>arr.forEach/map...(&#x5FAA;&#x73AF;&#x56DE;&#x8C03;&#x51FD;&#x6570;, &#x5E0C;&#x671B;this&#x6307;&#x5411;&#x8C01;); //&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x4E0D;&#x7ECF;&#x5E38;&#x7528;</p>
<ul>
<li>arr.reduce()</li>
<li>arr.reduceRight()</li>
</ul>
<h3 id="foreach">forEach()</h3>
<pre><code class="lang-js">&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-keyword">let</span> arr = [<span class="hljs-string">&apos;apple&apos;</span>, <span class="hljs-string">&apos;banana&apos;</span>, <span class="hljs-string">&apos;orange&apos;</span>, <span class="hljs-string">&apos;tomato&apos;</span>];
    arr.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">value, index, arr</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>, value, index, arr); 
        <span class="hljs-comment">//window &apos;apple&apos; 0 [&apos;apple&apos;, &apos;banana&apos;, &apos;orange&apos;, &apos;tomato&apos;]</span>
        <span class="hljs-comment">//...</span>
    });
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">// &#x6307;&#x5B9A;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;</span>
&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-keyword">let</span> json = {
        name:<span class="hljs-string">&apos;liuda&apos;</span>
    }

    <span class="hljs-keyword">let</span> arr = [<span class="hljs-string">&apos;apple&apos;</span>, <span class="hljs-string">&apos;banana&apos;</span>, <span class="hljs-string">&apos;orange&apos;</span>, <span class="hljs-string">&apos;tomato&apos;</span>];
    arr.forEach(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">value, index, arr</span>) </span>{
        <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>, value, index, arr); 
        <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>.name); <span class="hljs-comment">//liuda</span>
    }, json);
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">//&#x4F7F;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;</span>
&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-keyword">let</span> arr = [<span class="hljs-string">&apos;apple&apos;</span>, <span class="hljs-string">&apos;banana&apos;</span>, <span class="hljs-string">&apos;orange&apos;</span>, <span class="hljs-string">&apos;tomato&apos;</span>];
    arr.forEach((value, index, arr) =&gt; {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">this</span>, value, index, arr);
        <span class="hljs-comment">// window, apple 0 [&apos;apple&apos;, &apos;banana&apos;, &apos;orange&apos;, &apos;tomato&apos;]</span>
        <span class="hljs-comment">// ...</span>
        <span class="hljs-comment">// &#x6CE8;: &#x4F7F;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x65F6;, this&#x6307;&#x7684;&#x662F;&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x65F6;&#x6240;&#x5728;&#x7684;&#x5BF9;&#x8C61;,&#x6B64;&#x5904;&#x6307;window</span>
        <span class="hljs-comment">// &#x5373;&#x4F7F;&#x8BBE;&#x7F6E;&#x4E86;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;, &#x672C;&#x4F8B;&#x4E2D;this&#x4F9D;&#x7136;&#x4EE3;&#x8868;window</span>
    });
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<h3 id="map">map()</h3>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [
        {title:&apos;aaa&apos;, read:100, hot:true},
        {title:&apos;bbb&apos;, read:200, hot:true},
        {title:&apos;ccc&apos;, read:300, hot:false},
    ];
    //map&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x6570;&#x636E;&#x4EA4;&#x4E92;&apos;&#x6620;&#x5C04;&apos;
    //&#x4E00;&#x822C;&#x914D;&#x5408;return, &#x5982;&#x679C;&#x4E0D;return, &#x76F8;&#x5F53;&#x4E8E;forEach()
    let newArr = arr.map((value, index, arr) =&gt; {
        console.log(value, index, arr);
        return 1;
    });
    console.log(newArr); //[1,1,1]
&lt;/script&gt;
</code></pre>
<pre><code class="lang-js">//&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;
&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [
        {title:&apos;aaa&apos;, read:100, hot:true},
        {title:&apos;bbb&apos;, read:200, hot:true},
        {title:&apos;ccc&apos;, read:300, hot:false},
    ];
    //map&#x4E00;&#x822C;&#x7528;&#x4E8E;&#x6570;&#x636E;&#x4EA4;&#x4E92;&apos;&#x6620;&#x5C04;&apos;
    //&#x4E00;&#x822C;&#x914D;&#x5408;return, &#x5982;&#x679C;&#x4E0D;return, &#x76F8;&#x5F53;&#x4E8E;forEach()
    let newArr = arr.map((value, index, arr) =&gt; {
        let json = {};
        json.t = `&#x54C8;&#x54C8;${value.title}`;
        json.r = value.read + 200;
        json.h = value.hot == true &amp;&amp; &apos;&#x771F;&#x68D2;!!&apos;;
        return json;
    });
    console.log(newArr);
    //{t: &apos;&#x54C8;&#x54C8;aaa&apos;, r: 300, h: &apos;&#x771F;&#x68D2;!!&apos;}
    //{t: &apos;&#x54C8;&#x54C8;bbb&apos;, r: 400, h: &apos;&#x771F;&#x68D2;!!&apos;}
    //{t: &apos;&#x54C8;&#x54C8;ccc&apos;, r: 500, h: false}
&lt;/script&gt;
</code></pre>
<h3 id="filter">filter</h3>
<pre><code class="lang-js">&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-comment">//arr.filter() &#x8FC7;&#x6EE4;&#x6389;&#x4E00;&#x4E9B;&#x4E0D;&#x5408;&#x683C;&#x7684;&#x503C;, &#x8FD4;&#x56DE;true&#x5219;&#x4E0D;&#x8FC7;&#x6EE4;</span>
    <span class="hljs-keyword">let</span> arr = [
        {title:<span class="hljs-string">&apos;aaa&apos;</span>, read:<span class="hljs-number">100</span>, hot:<span class="hljs-literal">true</span>},
        {title:<span class="hljs-string">&apos;bbb&apos;</span>, read:<span class="hljs-number">200</span>, hot:<span class="hljs-literal">true</span>},
        {title:<span class="hljs-string">&apos;ccc&apos;</span>, read:<span class="hljs-number">300</span>, hot:<span class="hljs-literal">false</span>},
    ];
    <span class="hljs-keyword">let</span> newArr = arr.filter((value, index, arr) =&gt; {
        <span class="hljs-keyword">return</span> value.hot == <span class="hljs-literal">true</span>;
    });
    <span class="hljs-built_in">console</span>.log(newArr);
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<h3 id="some">some</h3>
<p>arr.some(): &#x67D0;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7B26;&#x5408;&#x5C31;&#x8FD4;&#x56DE;true</p>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [&apos;apple&apos;, &apos;banana&apos;, &apos;orange&apos;];
    let isExist = arr.some((value, index, arr) =&gt; {
        return value == &apos;banana&apos;;
    });
    console.log(isExist); //true
&lt;/script&gt;
</code></pre>
<h3 id="every">every</h3>
<p>arr.every(): &#x6240;&#x6709;&#x5143;&#x7D20;&#x90FD;&#x7B26;&#x5408;&#x5C31;&#x8FD4;&#x56DE;true</p>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    //arr.some() &#x67D0;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7B26;&#x5408;&#x5C31;&#x8FD4;&#x56DE;true
    let arr = [&apos;apple&apos;, &apos;banana&apos;, &apos;orange&apos;];
    let isSomeMatch = arr.every((value, index, arr) =&gt; {
        return value.length &gt; 3;
    });
    console.log(isSomeMatch); //true

    let isEveryMatch =  arr.every((value, index, arr) =&gt; {
        return value.length &lt; 3;
    });
    console.log(isEveryMatch); //false
&lt;/script&gt;
</code></pre>
<h3 id="reduce">reduce</h3>
<p>arr.reduce(&#x524D;&#x4E00;&#x4E2A;&#x65E0;&#x7D20;, &#x5F53;&#x524D;&#x5143;&#x7D20;, &#x7D22;&#x5F15;, &#x6570;&#x7EC4;&#x672C;&#x8EAB;), arr.reduce(prev, cur, index, arr)</p>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [1,2,3,4,5,6,7,8,9,10];

    let result = arr.reduce((prev, cur, index, arr) =&gt; {
        return prev + cur;
    });
    console.log(result); //55
&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [2,2,3];
     //4^3 
    let result = arr.reduce((prev, cur, index, arr) =&gt; {
        return Math.pow(prev, cur); //
    });
    console.log(result); //512
    console.log((2**2)**3); //512
     console.log(Math.pow(4, 3));
&lt;/script&gt;
</code></pre>
<h3 id="reduceright">reduceRight()</h3>
<p>&#x548C;reduce&#x7C7B;&#x4F3C;, &#x53EA;&#x662F;&#x4ECE;&#x53F3;&#x5F80;&#x5DE6;</p>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [2,2,3];
    let result = arr.reduceRight((prev, cur, index, arr) =&gt; {
        return Math.pow(prev, cur); //
    });
    console.log(result); //81
    console.log((3**2)**2); //81
&lt;/script&gt;
</code></pre>
<h3 id="forof">for...of</h3>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [&apos;apple&apos;,&apos;banana&apos;,&apos;pear&apos;];
    for (let val of arr) {
        console.log(val);
    }
    for (let index of arr.keys()) {
        console.log(index);    
    }
    for (let item of arr.entries()) {
        console.log(item);
    }
    for (let [key, value] of arr.entries()) {
        console.log(key, value);
    }
&lt;/script&gt;
</code></pre>
<h3 id="&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;&#x5728;&#x6570;&#x7EC4;&#x4E0A;&#x7684;&#x8FD0;&#x7528;">&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;...&#x5728;&#x6570;&#x7EC4;&#x4E0A;&#x7684;&#x8FD0;&#x7528;</h3>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [&apos;apple&apos;,&apos;banana&apos;,&apos;pear&apos;];
    let arr2 = [...arr]; // &#x4F7F;&#x7528;&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;copy&#x6570;&#x7EC4; &#x76F8;&#x5F53;&#x4E8E;: let arr2 = Array.from(arr)
    console.log(arr2);
&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    window.onload=function() {
        alert(&quot;hello&quot;);
        let aLi = document.querySelectorAll(&apos;ul li&apos;); //&#x6B64;&#x65F6;aLi&#x662F;object, &#x4E0D;&#x662F;&#x6570;&#x7EC4;
        let arrLi = [...aLi];
        arrLi.push(&apos;hello&apos;);
        console.log(arrLi);    
    };
&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    let str = &apos;Strive&apos;;
    //let arr = str.split(&apos;&apos;); 
    //console.log(arr); // [&apos;S&apos;, &apos;t&apos;, &apos;r&apos;, &apos;i&apos;, &apos;v&apos;, &apos;e&apos;]
    arr = Array.from(str);
    console.log(arr); // [&apos;S&apos;, &apos;t&apos;, &apos;r&apos;, &apos;i&apos;, &apos;v&apos;, &apos;e&apos;]

    //Array.from(&#x7C7B;&#x6570;&#x7EC4;&#x53C2;&#x6570;) &#x7528;&#x4E8E;&#x628A;&#x7C7B;&#x6570;&#x7EC4;&#x53C2;&#x6570;&#x5316;&#x4E3A;&#x6570;&#x7EC4;,&#x6240;&#x4EE5;&#x7C7B;&#x6570;&#x7EC4;&#x53C2;&#x6570;,&#x5373;&#x6B64;&#x53C2;&#x6570;&#x6709;.length&#x5C5E;&#x6027;
&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    let str = &apos;Strive!&apos;;
    arr = [...str];
    console.log(arr); // [&apos;S&apos;, &apos;t&apos;, &apos;r&apos;, &apos;i&apos;, &apos;v&apos;, &apos;e&apos;]
&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    let json = {
        0:&apos;apple&apos;,
        1:&apos;banana&apos;,
        2:&apos;orange&apos;,
        length:3 //&#x6709;length
    };
    let arr = Array.from(json);
    console.log(arr); // [&apos;apple&apos;, &apos;banana&apos;, &apos;orange&apos;]
&lt;/script&gt;
</code></pre>
<h3 id="arrayof">Array.of()</h3>
<pre><code class="lang-js">&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-keyword">let</span> arr = <span class="hljs-built_in">Array</span>.of(<span class="hljs-string">&apos;apple&apos;</span>, <span class="hljs-string">&apos;banana&apos;</span>, <span class="hljs-string">&apos;orange&apos;</span>); <span class="hljs-comment">//&#x628A;&#x4E00;&#x7EC4;&#x503C;&#x8F6C;&#x6210;&#x6570;&#x7EC4;</span>
    <span class="hljs-built_in">console</span>.log(arr);
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<h3 id="arrfind">arr.find()</h3>
<pre><code class="lang-js">&lt;script type=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;
    <span class="hljs-keyword">let</span> arr = [<span class="hljs-number">23</span>, <span class="hljs-number">90</span>, <span class="hljs-number">101</span>, <span class="hljs-number">80</span>, <span class="hljs-number">100</span>];
    <span class="hljs-comment">//&#x67E5;&#x627E;&#x7B2C;&#x4E00;&#x4E2A;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x6570;&#x7EC4;&#x6210;&#x5458;</span>
    <span class="hljs-keyword">let</span> result = arr.find((val, index, arr) =&gt; {
        <span class="hljs-keyword">return</span> val &gt; <span class="hljs-number">100</span>;
    });
    <span class="hljs-built_in">console</span>.log(result);
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<h3 id="arrfindindex">arr.findIndex()</h3>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = [23, 90, 101, 80, 100];
    // &#x67E5;&#x627E;&#x7B2C;&#x4E00;&#x4E2A;&#x7B26;&#x5408;&#x6761;&#x4EF6;&#x7684;&#x6570;&#x7EC4;&#x6210;&#x5458;
    let result = arr.findIndex((val, index, arr) =&gt; {
        return val &gt; 90; // &#x6CA1;&#x627E;&#x5230;&#x8FD4;&#x56DE;-1
    });
    console.log(result); //2
&lt;/script&gt;
</code></pre>
<h3 id="arrfill">arr.fill()</h3>
<p>arr.fill(&#x586B;&#x5145;&#x7684;&#x4E1C;&#x897F;,&#x5F00;&#x59CB;&#x4F4D;&#x7F6E;,&#x7ED3;&#x675F;&#x4F4D;&#x7F6E;)</p>
<pre><code class="lang-js">&lt;script type=&quot;text/javascript&quot;&gt;
    let arr = new Array(5);
    arr.fill(&apos;&#x9ED8;&#x8BA4;&#x503C;&apos;, 1, 3);
    console.log(arr); //[&#x7A7A;&#x767D;, &apos;&#x9ED8;&#x8BA4;&#x503C;&apos;, &apos;&#x9ED8;&#x8BA4;&#x503C;&apos;, &#x7A7A;&#x5C5E;&#x6027; &#xD7; 2]
&lt;/script&gt;
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="函数.html" class="navigation navigation-prev " aria-label="Previous page: 函数">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="对象.html" class="navigation navigation-next " aria-label="Next page: 对象">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"数组","level":"1.6","depth":1,"next":{"title":"对象","level":"1.7","depth":1,"path":"对象.md","ref":"对象.md","articles":[]},"previous":{"title":"函数","level":"1.5","depth":1,"path":"函数.md","ref":"函数.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"数组.md","mtime":"2021-11-29T13:28:01.703Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-02-17T15:54:39.156Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

